/************************************************
 * Case Detail
*************************************************/

//ipPort = '10.58.88.212:8080';

Ext.define('CaseDetail', {
	extend: 'Ext.data.Model',
	fields: [
	         'id', 'name', 'catalogId',	'profilegroupId',	
	         {name:'steps', persist:true},
	         {name:'subcases', persist:true}
	         ],
	hasMany: [{model:'CaseStep', name:'steps'}, {model:'SubCase', name:'subcases'}],
	proxy: {
		//type: 'ajax',
		//url: 'caseDetail.js',
		type: 'rest',
		url: 'http://' + ipPort + '/bpccase',
		/*reader: {
			type: 'json',
			root: 'Case'
		},*/
		reader: Ext.create('CaseReader',{
			root: 'Case'
		}),
		writer: {
			type: 'json',
			root: 'Case'
		}
	}
});
/*
Ext.define('CaseDetailInList', {
	extend: 'CaseDetail',
	proxy: {
		type: 'rest', 
		url: 'http://10.58.88.212:8080/BpcTesterWeb/bpccase',
		reader: {
			type: 'json',
			root: 'Case'
		},
		writer: {
			type: 'json',
			root: 'Case'
		}
	}
});
*/
Ext.define("CaseStep", {
	extend: "Ext.data.Model",
	fields:[
	        'id', 'name', 'desc', 'url', 'method', 'format', 'profile', 'request', 'response', 'header'
	        ],
	belongsTo: 'CaseDetail'
});

Ext.define("SubCase", {
	extend: 'Ext.data.Model',
	fields: ['id', 'name', {name:'params', persist:true}],
	hasMany: {model:'Param', name:'params'}
});


Ext.define("Param", {
	extend: 'Ext.data.Model',
	fields: ['name', 'value'],
	belongsTo: 'SubCase'
});

/************************************************
 * Case List
*************************************************/
Ext.define("Catalog", {
	extend: "Ext.data.Model",
	fields: ['id', 'name'],
	proxy: {
		type: 'rest',
		url: 'http://' + ipPort + '/bpcsavecatalog',
		//type: 'ajax',
		//url: 'createCatalog.txt',
		reader: {
			type: 'json',
			root: 'Catalog',
			messageProperty: 'msg'
		},
		writer: {
			type: 'json',
			root: 'Catalog',
			messageProperty: 'msg'
		}
	}
});
